Skip to content

sdk: Fix walk_submodel() skipping Entity and Operation children#465

Merged
s-heppner merged 3 commits into
eclipse-basyx:developfrom
rwth-iat:fix/issue-423-walk-submodel-entity-operation
Apr 21, 2026
Merged

sdk: Fix walk_submodel() skipping Entity and Operation children#465
s-heppner merged 3 commits into
eclipse-basyx:developfrom
rwth-iat:fix/issue-423-walk-submodel-entity-operation

Conversation

@zrgt

@zrgt zrgt commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #423.

traversal.walk_submodel() was only recursing into SubmodelElementCollection.value and
SubmodelElementList.value, missing two other container types defined by the AAS specification:

  • Entity.statement
  • Operation.input_variable, Operation.output_variable, Operation.in_output_variable

This caused a concrete data-loss bug: File SubmodelElements nested inside an Entity or
Operation were silently dropped from the file_store when reading AASX files
(AASXReader._collect_supplementary_files uses walk_submodel to find all File elements).

Changes

  • sdk/basyx/aas/util/traversal.py: Extracted element-level recursion into a private helper
    _walk_submodel_helper() that handles all four container types. The post-order traversal
    (children before parent) is preserved and works correctly for arbitrary nesting
    (e.g. Entity inside Operation.input_variable, SubmodelElementCollection inside
    Entity.statement).

  • sdk/test/util/test_traversal.py (new): 13 unit tests covering basic traversal, Entity
    statements, Operation variables, nested combinations, empty containers, and two explicit
    regression tests for issue traversal.walksubmodel(): Child Submodel Elements of Entity and Operation are skipped #423.

Fixes eclipse-basyx#423. The traversal now recurses into Entity.statement and
Operation.input_variable/output_variable/in_output_variable, so
File SubmodelElements nested inside these containers are no longer
silently dropped when reading AASX files.

Adds test_traversal.py with 13 unit tests covering the fix and
regression cases.
Comment thread sdk/basyx/aas/util/traversal.py Outdated
Comment thread sdk/test/util/test_traversal.py Outdated
- Extract public walk_submodel_element() helper that yields all
  descendants of a given SubmodelElement (but not the element itself),
  replacing the private module-level _walk_submodel_helper()
- Narrow walk_submodel() signature to accept only Submodel
- Update tests: use assertCountEqual (order-agnostic), rename
  post_order test methods, and use walk_submodel_element where applicable
@zrgt zrgt requested a review from s-heppner April 13, 2026 10:15

@s-heppner s-heppner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the failing CI check. Other than that, this LGTM!

@zrgt zrgt requested a review from s-heppner April 21, 2026 12:02
@s-heppner s-heppner merged commit 702d74e into eclipse-basyx:develop Apr 21, 2026
15 checks passed
@s-heppner s-heppner deleted the fix/issue-423-walk-submodel-entity-operation branch April 21, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants